home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -coverdisks- / 126a / football / user / cup_viewhistory.rexx < prev    next >
OS/2 REXX Batch file  |  1999-05-22  |  5KB  |  188 lines

  1. /* ***********************************************************************
  2.  
  3.    VIEW TEAM SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       091297   First release.
  11.            151297   Tidied display.
  12.            210499   Added support for CloseCup. History file would not be
  13.                     found as it did not have the date appended to the
  14.                     filename.
  15.  
  16. **************************************************************************
  17.  
  18. Procedure
  19. ---------
  20.  
  21. 1. Check file exists. If it doesn't, format a new filename from the
  22.    original, and then check this file.
  23. 2. Open '.cfh' file and read in winners, storing them and if the name
  24.    appears more than once, increment the number of wins for that team.
  25. 3. Read '.cfh' file in and store 'needed' lines.
  26. 4. Write teams for winners out to temp file and sort.
  27. 4. Check array and set marker if third place is found.
  28. 5. Display message. Display winners, runnersup, third place and fourth.
  29. 6. Read temp file and display winners with total wins. Exit.
  30.  
  31. ************************************************************************** */
  32. PARSE ARG league_stuff
  33.  
  34. version      = 1
  35. input_file   = '.cfh'
  36. first        = '*WINNER='
  37. second       = '*RUNNERUP='
  38. second       = '*THIRD='
  39. second       = '*FOURTH='
  40. cupnm        = '** History for '
  41. separator    = '*'
  42. teams.       = '???'
  43. wins.        = '???'
  44. lines.       = '???'
  45. counter      = 0
  46.  
  47.  
  48. league_file = "Data/" || league_stuff
  49.  
  50. if exists(league_file || input_file) = 0  then do
  51.    parse var league_file nlf "_" .
  52.    if exists(nlf || input_file) = 0 then exit
  53.    league_file = nlf
  54. end
  55.  
  56. if open(datafile,league_file || input_file,'r') then do
  57.    do while ~eof(datafile)
  58.       line = readln(datafile)
  59.       if pos(cupnm,line) > 0 then
  60.          cupname = delstr(line,1,15)
  61.       if pos(first,line) > 0 then do
  62.          name = delstr(line,1,8)
  63.          notin = 0
  64.          do i=1 to counter
  65.             if pos(name,teams.i) > 0 then do
  66.                wins.i = wins.i + 1
  67.                notin = 1
  68.             end
  69.          end
  70.          if notin = 0 then do
  71.             counter = counter + 1
  72.             teams.counter = name
  73.             wins.counter  = 1
  74.          end
  75.       end
  76.    end
  77.    close(datafile)
  78. end
  79. else do
  80.    say
  81.    say "ERROR :    (ViewHistory)"
  82.    say
  83.    say "Cannot open '"league_file||input_file"' for reading."
  84.    exit
  85. end
  86.  
  87. linect = 0
  88. if open(datafile,league_file || input_file,'r') then do
  89.    do while ~eof(datafile)
  90.       line = readln(datafile)
  91.       if pos('**',line) = 0 & length(line) > 2 & line ~= '' then do
  92.          linect = linect + 1
  93.          lines.linect = line
  94.       end
  95.    end
  96.    close(datafile)
  97. end
  98. else do
  99.    say
  100.    say "ERROR :    (ViewHistory)"
  101.    say
  102.    say "Cannot open '"league_file||input_file"' for reading."
  103.    exit
  104. end
  105.  
  106. if counter > 1 then do
  107.    if open(datafile,"RAM:Football.tempcup",'w') then do
  108.       do i=1 to counter
  109.          writeln(datafile,left(wins.i,4)"     "teams.i)
  110.       end
  111.       close(datafile)
  112.    end
  113.    else do
  114.       say
  115.       say "ERROR :    (ViewHistory)"
  116.       say
  117.       say "Cannot create temporary file."
  118.       exit
  119.    end
  120.    address command 'Exec/Sort4Chars '
  121. end
  122.  
  123. thirdp = 0
  124. do i=1 to linect
  125.    if pos(third,lines.i) > 0 then do
  126.       thirdp = 1
  127.       leave
  128.    end
  129. end
  130.  
  131. say
  132. say center("Display Cup History for "cupname,78)
  133. say "-------------------------------------------------------------------------------"
  134. say
  135.  
  136. do i=1 to linect
  137.    name = delstr(lines.i,1,8)
  138.    say "Winner       : "upper(name)
  139.    i = i + 1
  140.    name = delstr(lines.i,1,10)
  141.    say "Runner-Up    : "name
  142.    if thirdp = 1 then do
  143.       i = i + 1
  144.       name = delstr(lines.i,1,7)
  145.       say "Third Place  : "name
  146.       i = i + 1
  147.       name = delstr(lines.i,1,8)
  148.       say "Fourth Place : "name
  149.       say
  150.    end
  151.    else
  152.       say
  153. end
  154. say
  155. say
  156. say "Wins     Team"
  157. say "-------------------------------------------------------------------------------"
  158. say
  159. i = 0
  160. if counter = 1 then do
  161.    say left(wins.1,4)"     "upper(teams.1)
  162.    say
  163. end
  164. else do
  165.    if open(datafile,"RAM:Football.tempcup",'r') then do
  166.       do while ~eof(datafile)
  167.          line = readln(datafile)
  168.          if i = 0 then do
  169.             say upper(line)
  170.             i = 1
  171.          end
  172.          else
  173.             say line
  174.       end
  175.       close(datafile)
  176.    end
  177.    else do
  178.       say
  179.       say "ERROR :    (ViewHistory)"
  180.       say
  181.       say "Cannot read temporary file of teams to display the table of winners."
  182.       exit
  183.    end
  184.    address command 'delete >NIL: RAM:Football.tempcup'
  185. end
  186. say "-------------------------------------------------------------------------------"
  187.  
  188. exit